```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JVM类生命周期详解</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .step-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            margin: 0 auto 20px;
            color: white;
            font-size: 24px;
        }
        .timeline {
            position: relative;
            max-width: 1200px;
            margin: 0 auto;
        }
        .timeline::after {
            content: '';
            position: absolute;
            width: 6px;
            background-color: #e2e8f0;
            top: 0;
            bottom: 0;
            left: 50%;
            margin-left: -3px;
            border-radius: 3px;
        }
        .timeline-card {
            padding: 10px 40px;
            position: relative;
            width: 50%;
            box-sizing: border-box;
        }
        .timeline-card::after {
            content: '';
            position: absolute;
            width: 25px;
            height: 25px;
            background-color: #6e8efb;
            border-radius: 50%;
            top: 15px;
            z-index: 1;
        }
        .left {
            left: 0;
        }
        .right {
            left: 50%;
        }
        .left::after {
            right: -12px;
        }
        .right::after {
            left: -12px;
        }
        .timeline-content {
            padding: 20px 30px;
            background-color: white;
            position: relative;
            border-radius: 8px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        @media screen and (max-width: 768px) {
            .timeline::after {
                left: 31px;
            }
            .timeline-card {
                width: 100%;
                padding-left: 70px;
                padding-right: 25px;
            }
            .timeline-card::after {
                left: 18px;
            }
            .left::after, .right::after {
                left: 18px;
            }
            .right {
                left: 0%;
            }
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6">JVM类生命周期深度解析</h1>
            <p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto leading-relaxed">
                从加载到卸载，全面理解Java类在JVM中的完整旅程
            </p>
            <div class="flex justify-center space-x-4">
                <a href="#timeline" class="px-6 py-3 bg-white text-purple-700 rounded-full font-medium hover:bg-opacity-90 transition duration-300">
                    <i class="fas fa-arrow-down mr-2"></i>探索生命周期
                </a>
                <a href="#mermaid" class="px-6 py-3 bg-white bg-opacity-20 rounded-full font-medium hover:bg-opacity-30 transition duration-300">
                    <i class="fas fa-project-diagram mr-2"></i>查看流程图
                </a>
            </div>
        </div>
    </section>

    <!-- Intro Section -->
    <section class="py-16 px-4 md:px-0">
        <div class="container mx-auto max-w-4xl">
            <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="p-8 md:p-10">
                    <p class="text-xl text-gray-700 mb-6 leading-relaxed">
                        一个类从诞生到卸载，大体分为如下几步: <span class="font-bold text-purple-600">类的加载</span>、<span class="font-bold text-blue-600">类的使用</span>、以及<span class="font-bold text-gray-600">类的卸载</span>。其中类的加载阶段又分为加载、链接、初始化。其中连接过程又包含了验证、准备和解析。
                    </p>
                    <div class="mt-8">
                        <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1691053909194-136973d0-97f2-4ce2-bf68-54d291ad4852.png" 
                             alt="类生命周期概览" 
                             class="w-full rounded-lg shadow-md">
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Timeline Section -->
    <section id="timeline" class="py-16 px-4 md:px-0 bg-gray-50">
        <div class="container mx-auto max-w-6xl">
            <h2 class="text-3xl font-bold text-center mb-12">生命周期详细步骤</h2>
            
            <div class="timeline">
                <!-- 加载阶段 -->
                <div class="timeline-card left">
                    <div class="timeline-content">
                        <div class="flex items-center mb-4">
                            <div class="step-icon bg-purple-500">
                                <i class="fas fa-cloud-download-alt"></i>
                            </div>
                            <h3 class="text-2xl font-bold ml-4 text-purple-600">加载阶段 (Loading)</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            在这个阶段，类的字节码被加载到JVM中。JVM通过类加载器来查找并加载类的字节码，然后将字节码转换为JVM内部的数据结构，如Class对象。
                        </p>
                        <div class="bg-gray-100 p-4 rounded-lg">
                            <p class="font-medium text-gray-800">加载阶段包含三个步骤：</p>
                            <ul class="list-disc pl-5 mt-2 space-y-1">
                                <li><span class="font-medium">加载</span>：由类加载器加载类的字节码文件，并创建一个对应的Class对象。</li>
                                <li><span class="font-medium">验证</span>：验证加载的字节码是否符合JVM规范，防止恶意代码。</li>
                                <li><span class="font-medium">准备</span>：为类的静态变量分配内存并初始化默认值。</li>
                            </ul>
                        </div>
                        <div class="mt-4">
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1706775661559-da477cf0-818e-4808-93d6-5885d8aa91c1.png" 
                                 alt="加载阶段图示" 
                                 class="w-full rounded-lg shadow-sm">
                        </div>
                    </div>
                </div>

                <!-- 链接阶段 -->
                <div class="timeline-card right">
                    <div class="timeline-content">
                        <div class="flex items-center mb-4">
                            <div class="step-icon bg-blue-500">
                                <i class="fas fa-link"></i>
                            </div>
                            <h3 class="text-2xl font-bold ml-4 text-blue-600">链接阶段 (Linking)</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            在这个阶段，对加载阶段生成的Class对象进行链接。链接是类加载过程的第二个阶段，它将字节码转换为JVM可以直接使用的格式。
                        </p>
                        <div class="bg-gray-100 p-4 rounded-lg">
                            <p class="font-medium text-gray-800">链接阶段包含三个子阶段：</p>
                            <ul class="list-disc pl-5 mt-2 space-y-1">
                                <li><span class="font-medium">验证</span>：检查字节码是否符合JVM规范，防止恶意代码或损坏的字节码。</li>
                                <li><span class="font-medium">准备</span>：为类的静态变量分配内存并初始化默认值。</li>
                                <li><span class="font-medium">解析</span>：将符号引用转换为直接引用，即将类、字段、方法等符号引用解析为内存地址。</li>
                            </ul>
                        </div>
                        <div class="mt-4">
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1706775788222-48a088f9-5433-410a-be24-684d8db84bad.png" 
                                 alt="链接阶段图示" 
                                 class="w-full rounded-lg shadow-sm">
                        </div>
                    </div>
                </div>

                <!-- 初始化阶段 -->
                <div class="timeline-card left">
                    <div class="timeline-content">
                        <div class="flex items-center mb-4">
                            <div class="step-icon bg-green-500">
                                <i class="fas fa-play"></i>
                            </div>
                            <h3 class="text-2xl font-bold ml-4 text-green-600">初始化阶段 (Initialization)</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            在这个阶段，对类进行初始化，即执行类的静态初始化块和静态变量赋值。这是类加载过程的最后一步。
                        </p>
                        <div class="bg-gray-100 p-4 rounded-lg">
                            <p class="font-medium text-gray-800">类的初始化在以下几种情况下会被触发：</p>
                            <ul class="list-disc pl-5 mt-2 space-y-1">
                                <li>创建类的实例</li>
                                <li>调用类的静态方法</li>
                                <li>访问类的静态变量</li>
                                <li>使用反射访问类</li>
                            </ul>
                        </div>
                        <div class="mt-4">
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1706776102501-2576756a-d2b1-420c-9c70-007e634c386e.png" 
                                 alt="初始化阶段图示" 
                                 class="w-full rounded-lg shadow-sm">
                        </div>
                    </div>
                </div>

                <!-- 使用阶段 -->
                <div class="timeline-card right">
                    <div class="timeline-content">
                        <div class="flex items-center mb-4">
                            <div class="step-icon bg-yellow-500">
                                <i class="fas fa-cogs"></i>
                            </div>
                            <h3 class="text-2xl font-bold ml-4 text-yellow-600">使用阶段 (Using)</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            在这个阶段，类被正常使用，可以创建对象实例，调用方法等。这是类生命周期中最长的阶段。
                        </p>
                        <div class="bg-gray-100 p-4 rounded-lg">
                            <p class="font-medium text-gray-800">使用阶段的主要活动：</p>
                            <ul class="list-disc pl-5 mt-2 space-y-1">
                                <li>创建类的实例对象</li>
                                <li>调用实例方法和类方法</li>
                                <li>访问和修改实例变量和类变量</li>
                                <li>通过反射操作类和对象</li>
                            </ul>
                        </div>
                        <div class="mt-4">
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1706776270511-3c6bd2c1-3907-44f7-860e-a6d44e6a99bf.png" 
                                 alt="使用阶段图示" 
                                 class="w-full rounded-lg shadow-sm">
                        </div>
                    </div>
                </div>

                <!-- 卸载阶段 -->
                <div class="timeline-card left">
                    <div class="timeline-content">
                        <div class="flex items-center mb-4">
                            <div class="step-icon bg-red-500">
                                <i class="fas fa-trash-alt"></i>
                            </div>
                            <h3 class="text-2xl font-bold ml-4 text-red-600">卸载阶段 (Unloading)</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            在这个阶段，类被从JVM中卸载。JVM在类不再被引用，并且没有任何线程执行该类的代码时，会将类从内存中卸载，释放相应的资源。
                        </p>
                        <div class="bg-gray-100 p-4 rounded-lg">
                            <p class="font-medium text-gray-800">卸载条件：</p>
                            <ul class="list-disc pl-5 mt-2 space-y-1">
                                <li>类的所有实例都已被回收</li>
                                <li>加载该类的ClassLoader已被回收</li>
                                <li>该类对应的java.lang.Class对象没有被任何地方引用</li>
                            </ul>
                        </div>
                        <div class="mt-4">
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1706776717682-0da58c2c-f21a-4d40-b116-94ef13b52aab.png" 
                                 alt="卸载阶段图示" 
                                 class="w-full rounded-lg shadow-sm">
                        </div>
                    </div>
                </div>
            </div>

            <!-- 注意事项 -->
            <div class="mt-16 bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="bg-yellow-50 px-6 py-4 border-b border-yellow-200">
                    <h3 class="text-xl font-bold text-yellow-700 flex items-center">
                        <i class="fas fa-exclamation-circle mr-2"></i> 重要注意事项
                    </h3>
                </div>
                <div class="p-6 md:p-8">
                    <p class="text-gray-700 leading-relaxed">
                        值得注意的是，类的生命周期可能因为类的加载和卸载条件而有所不同。一些特殊情况下，类可能经历不完整的生命周期，比如被动引用类，它不会触发初始化阶段。类加载和初始化的时机是由JVM控制的，JVM会根据实际情况来触发类的加载和初始化。
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Mermaid Diagram Section -->
    <section id="mermaid" class="py-16 px-4 md:px-0 bg-white">
        <div class="container mx-auto max-w-6xl">
            <h2 class="text-3xl font-bold text-center mb-12">类生命周期流程图</h2>
            <div class="bg-gray-50 p-6 rounded-xl shadow-inner">
                <div class="mermaid">
                    graph TD
                    A[开始] --> B[加载 Loading]
                    B --> C[链接 Linking]
                    C --> D[初始化 Initialization]
                    D --> E[使用 Using]
                    E --> F{是否满足卸载条件?}
                    F --> |是| G[卸载 Unloading]
                    F --> |否| E
                    G --> H[结束]

                    subgraph 加载阶段
                    B --> B1[加载字节码]
                    B1 --> B2[创建Class对象]
                    end

                    subgraph 链接阶段
                    C --> C1[验证]
                    C1 --> C2[准备]
                    C2 --> C3[解析]
                    end

                    subgraph 初始化阶段
                    D --> D1[执行<clinit>]
                    D1 --> D2[初始化静态变量]
                    end

                    style A fill:#f8fafc,stroke:#6b7280,stroke-width:2px
                    style H fill:#f8fafc,stroke:#6b7280,stroke-width:2px
                    style B fill:#e9d5ff,stroke:#8b5cf6,stroke-width:2px
                    style C fill:#dbeafe,stroke:#3b82f6,stroke-width:2px
                    style D fill:#dcfce7,stroke:#22c55e,stroke-width:2px
                    style E fill:#fef9c3,stroke:#eab308,stroke-width:2px
                    style F fill:#fee2e2,stroke:#ef4444,stroke-width:2px
                    style G fill:#f3e8ff,stroke:#a855f7,stroke-width:2px
                </div>
            </div>
        </div>
    </section>

    <!-- Key Concepts Section -->
    <section class="py-16 px-4 md:px-0 bg-gray-50">
        <div class="container mx-auto max-w-6xl">
            <h2 class="text-3xl font-bold text-center mb-12">核心概念解析</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <!-- 类加载器 -->
                <div class="card-hover bg-white rounded-xl shadow-lg overflow-hidden">
                    <div class="bg-purple-100 px-6 py-4">
                        <h3 class="text-xl font-bold text-purple-700 flex items-center">
                            <i class="fas fa-box-open mr-2"></i> 类加载器 (ClassLoader)
                        </h3>
                    </div>
                    <div class="p-6">
                        <p class="text-gray-700 mb-4">
                            类加载器是JVM用来加载类文件的组件。Java中有三种主要的类加载器：
                        </p>
                        <ul class="list-disc pl-5 space-y-2">
                            <li><span class="font-medium">启动类加载器 (Bootstrap ClassLoader)</span>：加载JVM核心类库</li>
                            <li><span class="font-medium">扩展类加载器 (Extension ClassLoader)</span>：加载Java扩展库</li>
                            <li><span class="font-medium">应用类加载器 (Application ClassLoader)</span>：加载用户类路径上的类</li>
                        </ul>
                        <div class="mt-4 bg-gray-100 p-4 rounded-lg">
                            <p class="font-medium text-gray-800">双亲委派模型：</p>
                            <p class="text-gray-700 mt-2">
                                类加载器在加载类时，首先会委托父类加载器尝试加载，只有当父类加载器无法加载时，自己才会尝试加载。
                            </p>
                        </div>
                    </div>
                </div>

                <!-- 被动引用 -->
                <div class="card-hover bg-white rounded-xl shadow-lg overflow-hidden">
                    <div class="bg-blue-100 px-6 py-4">
                        <h3 class="text-xl font-bold text-blue-700 flex items-center">
                            <i class="fas fa-exclamation-triangle mr-2"></i> 被动引用
                        </h3>
                    </div>
                    <div class="p-6">
                        <p class="text-gray-700 mb-4">
                            被动引用是指那些不会触发类初始化的情况。了解这些情况有助于理解类加载的精确机制。
                        </p>
                        <ul class="list-disc pl-5 space-y-2">
                            <li>通过子类引用父类的静态字段，不会导致子类初始化</li>
                            <li>通过数组定义来引用类，不会触发此类的初始化</li>
                            <li>引用类的常量(static final)不会触发初始化</li>
                        </ul>
                        <div class="mt-4 bg-gray-100 p-4 rounded-lg">
                            <p class="font-medium text-gray-800">示例代码：</p>
                            <pre class="bg-gray-800 text-gray-100 p-3 rounded mt-2 overflow-x-auto">
<code>class SuperClass {
    static { System.out.println("SuperClass init!"); }
    public static int value = 123;
}

class SubClass extends SuperClass {
    static { System.out.println("SubClass init!"); }
}

// 被动引用示例1
System.out.println(SubClass.value);  // 只会输出"SuperClass init!"

// 被动引用示例2
SuperClass[] sca = new SuperClass[10];  // 不会输出任何初始化信息</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-10 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">深入探索Java技术细节</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" 
                       class="text-gray-300 hover:text-white transition duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i> 技术小馆地址: http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```